package com.zy.controller;

import com.zy.Vo.HousedVo;
import com.zy.Vo.ResultVo;
import com.zy.pojo.Housed;
import com.zy.service.HousedService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/housed")
public class HousedControlleer {
    @Resource
    private HousedService housedService;

    @GetMapping("/pagehousedlist/{pageNo}/{pageSize}")
    public ResultVo getHousedPageList(@PathVariable Integer pageNo, @PathVariable Integer pageSize, HousedVo housedVo){
        return ResultVo.sucess(housedService.getPageHousedList(pageNo,pageSize,housedVo));
    }
    @GetMapping("/housedlist")
    public Object getHousedList(){
        return housedService.getHousedList();
    }

    @PostMapping("/housedaddRk")
    public ResultVo getHousedAdd(@RequestBody Housed housed, HttpSession session){
        try{
            housedService.HousedAdd(housed);
            housedService.HousedDelete(housed.getId());
            return ResultVo.sucess("入库商成功!!!");
        }catch (Exception e){
            return ResultVo.fail("入库商品失败",e);//打印错误日志
        }
    }
}
